package 寒假刷题;

public class 增减字符串匹配 {
    public int[] diStringMatch(String s) {
        int len = s.length();
        int[] ints = new int[len + 1];
        int start = 0;
        int end = len;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (c=='I'){
                ints[i] = start++;
            }
            else{
                ints[i] = end--;
            }
        }
        ints[len] = end;
        return ints;
    }
}
